<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>欢迎注册</title>
    <!-- <link rel="stylesheet" type="text/css" href="style/public.css"/> -->
    <link rel="stylesheet" type="text/css" href="css/register.css" />
    <!-- <link rel="stylesheet" type="text/css" href="style/rl.css"/> -->
</head>

<body>
    <div class="header">
        <div class="container">
            <div class="header-yi">
                <div class="header-logo">
                    <a href="index.html"><img src="imges/logo.png"></a>
                </div>
                <p class="header-text">欢迎注册</p>
            </div>
            <div class="header-er">
                已有账号？请
                <a href="login.html">登录</a>
            </div>
        </div>
    </div>
    <div class="body">
        <div class="container" style="height: 400px;">
            <div class="body-input">
                <span>用户名</span>
                <input type="text" class="name">
            </div>
            <div class="body-input body-input-bg">
                <span>设置密码</span>
                <input type="password" class="password">
            </div>
            <div class="body-input">
                <span>年龄</span>
                <input type="text" class="age">
            </div>
            <div class="body-input">
                <span>电话</span>
                <input type="number" class="dianhua">
            </div>
            <div class="body-input">
                <span>签名</span>
                <input type="input" class="sfz">
            </div>
            <div class="body-btn">
                <button class="btn">确认</button>
            </div>
        </div>
    </div>
    <div class="foot">
        姓名：xxx 学号：xxx
    </div>
    <script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript">
        $(function() {
            $('.btn').click(function() {
                let name = $('.name').val();
                let password = $('.password').val();
                let age = $('.age').val();
                let dianhua = $('.dianhua').val();
                let sfz = $('.sfz').val();
                if (name != '' && password != '' && age != '' && dianhua != '' && sfz != '') {
                    $.ajax({
                        url: 'http://localhost:2380/api/UserKong/zuce',
                        data: {
                            name,
                            password,
                            age,
                            dianhua,
                            sfz,
                            quanxian: '用户'
                        },
                        type: 'get',
                        datatype: 'json',
                        success: function(dt) {
                            if (dt != false) {
                                alert('注册成功！')
                                sessionStorage.setItem("zcuser", JSON.stringify(dt))
                                location.href = 'login.html';
                            } else {
                                alert('昵称已被别人使用！');
                            }
                        }
                    })
                } else {
                    alert('文本框不能为空！');
                }
            })
        })
    </script>
</body>

</html>